import nltk
from nltk import pos_tag
from nltk.tokenize import word_tokenize

# 手动指定资源路径
nltk.data.path.append('C:/Users/93204/AppData/Roaming/nltk_data')

# 下载资源
# nltk.download('punkt')
# nltk.download('averaged_perceptron_tagger')

print(f"nltk.data.path:{nltk.data.path}")

text = "This is a test sentence."
words = word_tokenize(text)
print(f"words: {words}")

# 使用英语标注器
tagged_words = pos_tag(words)
print(f"tagged_words: {tagged_words}")
